﻿-- Define the relationship between TypeRoleAccess and SecurityRole
ALTER TABLE [dbo].[TypeRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_TypeRoleAccess_SecurityRole] FOREIGN KEY([SecurityRole])
REFERENCES [dbo].[SecurityRole] ([RoleId])
ON DELETE NO ACTION
GO
-- Define the relationship between TypeRoleAccess and Type
ALTER TABLE [dbo].[TypeRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_TypeRoleAccess_Type] FOREIGN KEY([Type])
REFERENCES [dbo].[Type] ([TypeId])
ON DELETE NO ACTION
GO
-- Define the relationship between TypeRoleAccess and Person
ALTER TABLE [dbo].[TypeRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_TypeRoleAccess_CreatedByPerson] FOREIGN KEY([CreatedBy])
REFERENCES [dbo].[Person] ([PersonId])
ON DELETE NO ACTION
GO
-- Define the relationship between TypeRoleAccess and Person
ALTER TABLE [dbo].[TypeRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_TypeRoleAccess_LastChangedBy] FOREIGN KEY([LastChangedBy])
REFERENCES [dbo].[Person] ([PersonId])
ON DELETE NO ACTION
GO
-- Define the relationship between TypeRoleAccess and Person
ALTER TABLE [dbo].[TypeRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_TypeRoleAccess_Person] FOREIGN KEY([Person])
REFERENCES [dbo].[Person] ([PersonId])
ON DELETE NO ACTION
GO